﻿//显示
$(function () {
    // 获取当前日期时间
    var now = new Date();
    var hours = ("0" + now.getHours()).slice(-2);
    var minutes = ("0" + now.getMinutes()).slice(-2);
    var seconds = ("0" + now.getSeconds()).slice(-2);
    var serialNumber = "RW" + hours + minutes + seconds;
    console.log(serialNumber)
    $("#taskMumber").val(serialNumber)
})
//选择工单
//function workOrderlist() {
//    layui.use('layer', function () {
//        $.ajax({
//            url: "/ProcessTask/ProcuredMondel",
//            type: "get",
//            data: { Token: localStorage.getItem("token") },
//            success: function (data) {
//                data = JSON.parse(data);
//                $("#workOrder").empty()
//                $("#workOrder").append('<option value="0">选择工单 </option>')
//                $(data).each(function () {
//                    $("#workOrder").append('<option value="' + this.BFid + '">' + this.BFNAME + '</option>')
//                })
//            }
//        })
//    });
//}


layui.use('layer', function () {
    var $ = layui.$;
    var layer = layui.layer;
    var util = layui.util;
    var form = layui.form;
    var table = layui.table;
    // 表单提交事件
    form.on('submit(demo-login)', function (data) {
        var field = data.field;
        console.log(field)
        $.ajax({
            url: '/ProcessTask/LocationProcessTaskAdd',
            type: 'post',
            data: { data: JSON.stringify(field), token: localStorage.getItem("token") },
            success: function (res) {
                var s = JSON.parse(res)
                console.log(res)
                if (s.code == 1) {
                    layer.alert("添加成功");
                    //setTimeout(function () {
                    //    location.reload();
                    //}, 2000);
                    location.href = "/ProcessTask/ProcessTaskShow";
                }
                else {
                    layer.alert("添加失败");
                }
            }
        })
        return false; // 阻止默认 form 跳转
    });

});

